<template>
  <div class="table-page-container">
    <div v-if="isHeaderSlotExist" :class="`${isShowCard ? 'card' : ''} page-header`">
      <slot name="header" />
    </div>
    <div :class="`${isShowCard ? 'card' : ''} page-table`">
      <div v-if="isOperationSlotExist" style="margin-bottom: 10px">
        <slot name="operation" />
      </div>
      <slot v-if="isTableSlotExist" name="table" />
      <slot v-if="isPageSlotExist" name="page" />
    </div>
  </div>
</template>
<script>
export default {
  props: {
    isShowCard: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {}
  },
  computed: {
    isHeaderSlotExist() {
      return this.$slots.header
    },
    isOperationSlotExist() {
      return this.$slots.operation
    },
    isTableSlotExist() {
      return this.$slots.table
    },
    isPageSlotExist() {
      return this.$slots.page
    }
  }
}
</script>
<style lang="scss" scoped>
.table-page-container {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;

  .page-header{
    padding-bottom: 18px;
  }

  .page-body {
    margin-top: 10px;

    ::v-deep.el-card__body {
      height: 100%;
      padding: 16px;
    }
  }

  .page-table {
    height: 100%;
    margin-top: 10px;

    ::v-deep.el-table {
      height: calc(100% - 80px);
    }
  }
}
</style>
